import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types'
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '批次名',
    align:"center",
    sorter: true,
    dataIndex: 'batchName'
   },
   {
    title: '描述',
    align:"center",
    dataIndex: 'description'
   },
   {
    title: '上线时间',
    align:"center",
    sorter: true,
    dataIndex: 'onlineTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
   {
    title: '批次类型',
    align:"center",
    sorter: true,
    dataIndex: 'batchType_dictText'
   },
   {
    title: '创建人',
    align:"center",
    dataIndex: 'createBy'
   },
   {
    title: '创建时间',
    align:"center",
    sorter: true,
    dataIndex: 'createTime'
   },
  //  {
  //   title: '更新人',
  //   align:"center",
  //   dataIndex: 'updateBy'
  //  },
  //  {
  //   title: '更新时间',
  //   align:"center",
  //   sorter: true,
  //   dataIndex: 'updateTime'
  //  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "批次名",
      field: "batchName",
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "描述",
      field: "description",
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "上线时间",
      field: "onlineTime",
      component: 'DatePicker',
      //colProps: {span: 6},
 	},
	{
      label: "批次类型",
      field: "batchType",
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"batch_type"
      },
      //colProps: {span: 6},
 	},
	{
      label: "创建人",
      field: "createBy",
      component: 'Input',
      //colProps: {span: 6},
 	},
     {
      label: "创建时间",
      field: "createTime",
      component: 'RangePicker',
      componentProps: {
          showTime:true
      },
      //colProps: {span: 6},
	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '批次名',
    field: 'batchName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入批次名!'},
          ];
     },
  },
  {
    label: '描述',
    field: 'description',
    component: 'InputTextArea',
  },
  {
    label: '上线时间',
    field: 'onlineTime',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入上线时间!'},
          ];
     },
  },
  {
    label: '批次类型',
    field: 'batchType',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"batch_type"
     },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
//子表单数据
//子表表格配置
export const batchStageColumns: JVxeColumn[] = [
    {
      title: '阶段',
      key: 'testStage',
      type: JVxeTypes.select,
      options:[],
      dictCode:"batch_test_stage",
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '开始时间',
      key: 'startTime',
      type: JVxeTypes.date,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '结束时间',
      key: 'endTime',
      type: JVxeTypes.date,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '备注',
      key: 'comments',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: 'test',
      key: 'test',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
  ]

// 高级查询数据
export const superQuerySchema = {
  batchName: {title: '批次名',order: 0,view: 'text', type: 'string',},
  description: {title: '描述',order: 1,view: 'textarea', type: 'string',},
  onlineTime: {title: '上线时间',order: 2,view: 'date', type: 'string',},
  batchType: {title: '批次类型',order: 3,view: 'list', type: 'string',dictCode: 'batch_type',},
  createBy: {title: '创建人',order: 4,view: 'text', type: 'string',},
  createTime: {title: '创建时间',order: 5,view: 'datetime', type: 'string',},
  updateBy: {title: '更新人',order: 6,view: 'text', type: 'string',},
  updateTime: {title: '更新时间',order: 7,view: 'datetime', type: 'string',},
  //子表高级查询
  batchStage: {
    title: '批次阶段',
    view: 'table',
    fields: {
        testStage: {title: '阶段',order: 0,view: 'list', type: 'string',dictCode: 'batch_test_stage',},
        startTime: {title: '开始时间',order: 1,view: 'date', type: 'string',},
        endTime: {title: '结束时间',order: 2,view: 'date', type: 'string',},
        comments: {title: '备注',order: 3,view: 'text', type: 'string',},
        test: {title: 'test',order: 4,view: 'text', type: 'string',},
    }
  },
};
